﻿@{
    ViewBag.Title = "字典管理";
    Layout = "~/Views/Shared/InfoMaste.cshtml";
}
<script language="javascript" type="text/javascript">
    //搜索配置表
    function doSearch() {
        $('#dg').datagrid('load', {
            dictValue: $('#dictValueCombobox').combobox('getValue'),
            dictName: "",
        });
    }

    function addDict() {
        $('#dlg').dialog('open');
        url = '/BasicManage/AddDictInfo';
    }

    function editDict() {
        var row = $('#dg').datagrid('getSelected');
        if (row) {
            $('#dlg').dialog('open').dialog('setTitle', '编辑');
            $('#fm').form('load', row);
            url = '/BasicManage/EditDictInfo'
        }
    }

    function delDict() {
        var row = $('#dg').datagrid('getSelected');
        if (!row) {
            Helper.Show('请选择需要删除的信息?');
            return false;
        }
        $.messager.confirm('提示信息', '您确认要删除吗?', function (r) {
            if (!r) { return false; }
            $.post("/BasicManage/DelDictInfo", { id: row.Id }, function (json) {
                Helper.Show(json.Msg);
                if (json.Code == 1) {
                    doSearch();
                }
            });
        });
    }
    function saveDict() {
        $('#fm').form('submit', {
            url: url,
            onSubmit: function () {
                return $(this).form('validate');
            },
            success: function (json) {
                var json = eval('(' + json + ')');
                $.messager.show({
                    title: '消息提示',
                    msg: json.Msg
                });
                if (json.Success) {
                    $('#fm').form('clear');
                    $('#dlg').dialog('close');
                    $('#dg').datagrid('reload');
                }
            }
        });
    }
</script>
<table id="dg" class="easyui-datagrid"  style="width:100%; height: 600px;"
       url="/BasicManage/GetDictInfoList" toolbar="#tb" title="字典列表" rownumbers="true"
       pagination="true" pagelist="[15]" fitcolumns="true" singleselect="true">
    <thead>
        <tr>
            <th field="ck" checkbox="true"></th>
            <th field="DictName" align="right" width="150">
                名称
            </th>
            <th field="DictType" align="right" width="150">
                类型
            </th>
            <th field="DictValue" align="right" width="150">
                值
            </th>
            <th field="Sort" align="right" width="150">
                排序
            </th>
        </tr>
    </thead>
</table>
<div id="tb" style="padding: 3px; height: auto;">
    <span>配置类型</span>
    <input class="easyui-combobox" id="dictValueCombobox" data-options="
				url: '/BasicManage/InitDictInfoListCombobox',
				method: 'post',
                valueField: 'DictValue',
                textField: 'DictName',
				panelHeight: 'auto'
                ">
    <div>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-add" plain="true" onclick="addDict()">添加</a>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-edit" plain="true" onclick="editDict()">编辑</a>
        <a href="javascript:" class="easyui-linkbutton" iconcls="icon-cut" plain="true" onclick="delDict()">删除</a>
        <a href="javascript:" class="easyui-linkbutton" plain="true" iconcls="icon-search" onclick="doSearch()">查询</a>
    </div>
</div>
<div id="dlg" class="easyui-dialog" title="字典" data-options="iconCls:'icon-save'"
     closed="true" style="width: 400px; height: 300px; padding: 10px 20px" buttons="#dlg-buttons" modal="true">
    <div class="ftitle">
    </div>
    <form id="fm" method="post" novalidate>
        <input name="Id" type="hidden" />
        <div class="fitem">
            <label>
                名称:
            </label>
            <input name="DictName" id="DictName" class="easyui-validatebox textbox" required="true" style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                类型:
            </label>
            <input name="DictType" id="DictType" class="easyui-validatebox textbox" required="true" style="width: 173px; height: 30px;" autocomplete="off" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                值:
            </label>
            <input name="DictValue" id="DictValue" class="easyui-validatebox textbox" required="true" style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
        <div class="fitem">
            <label>
                排序:
            </label>
            <input name="Sort" id="Sort" class="easyui-validatebox textbox" required="true" value="1" style="width: 173px; height: 30px;" autocomplete="off" />
        </div>
    </form>
</div>
<div id="dlg-buttons">
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-ok" onclick="saveDict()">保存</a>
    <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')">取消</a>
</div>
